<?php
# if application("Jira_Key") = "" then application("Jira_Key") = readRegistryKey("HKEY_LOCAL_MACHINE\SOFTWARE\PolitieMon\JiraAccess")
# if application("Agenda_Feed") = "" then application("Agenda_Feed") = readRegistryKey("HKEY_LOCAL_MACHINE\SOFTWARE\PolitieMon\AgendaFeed")

# function sendCDOEmail(wstrMailFrom, wstrMailTo, wstrMailSubject, wstrMailMessage) ' stuur een e-mail
# 	dim lobjMailer
# 	set lobjMailer = Server.CreateObject("CDO.Message")

# 	'==This section provides the configuration information for the remote SMTP server.
# 	'==Normally you will only change the server name or IP.
# 	lobjMailer.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 

# 	'Name or IP of Remote SMTP Server
# 	lobjMailer.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.xs4all.nl"

# 	'Server port (typically 25)
# 	lobjMailer.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 

# 	lobjMailer.Configuration.Fields.Update

# 	'==End remote SMTP server configuration section==
#     lobjMailer.Subject 	= wstrMailSubject
# 	lobjMailer.To		= wstrMailTo
# 	lobjMailer.From		= wstrMailFrom
# 	lobjMailer.TextBody		= wstrMailMessage

# 	if trim(wstrMailTo) <> "" then Call lobjMailer.Send

# 	set lobjMailer = Nothing
# end function

# function readRegistryKey(RegPath)
# 	Dim objRegistry, Key
# 	Set objRegistry = Server.CreateObject("Wscript.shell")
# 	Key = objRegistry.RegRead(RegPath)
# 	readRegistryKey = Key
# end function

function generatePage($preview, $nextpage, $rssTitle, $rssImage, $rssInhoud) {
	generatePageTimed($preview, $nextpage, $rssTitle, $rssImage, $rssInhoud, 18);
}

function generatePageTimed($preview, $nextpage, $rssTitle, $rssImage, $rssInhoud, $seconden) {
	$pageData = new stdClass();
	$pageData->preview = $preview;
	$pageData->nextpage = $nextpage;
	$pageData->rssTitle = $rssTitle;
	$pageData->rssImage = $rssImage;
	$pageData->rssImageAttr = "align=\"left\" height=\"50%\"";
	$pageData->rssInhoud = $rssInhoud;
	$pageData->background = "../../images/bg.jpg";
	$pageData->seconden = $seconden;
	ob_start();
	require('views/generatePageEx.php');
	ob_end_flush();
}

function niceTitel($txt) {
	if (substr($txt, 0, 1) == "(" && substr($txt, -1) == ")") {
		return substr($txt, 1, -1);
	}
	return $txt;
}

function formatTitel($txt) {
	if (substr($txt, 0, 1) == "(" && substr($txt, -1) == ")") {
		return "";
	}
	return $txt;
}

// sub generatePageEx(preview, nextpage, rssTitle, rssImage, rssImageAttr, rssInhoud, background, seconden)
// 	%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

// <html>
// <head>
// 	<title><%=rssTitle%></title>
// 	<LINK REL="stylesheet" TYPE="text/css" HREF="../../style/kabelkrant.css">
// 	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
// 	<script src="http://jquery-textfill.github.io/jquery-textfill/jquery.textfill.min.js"></script>
// 	<script src="../../script/narrowcast.js"></script>
// 	<script language='javascript'>
// 		function nextpage() {
// 			<% if preview <> "yes" then %>
// 			self.location.href = "../../kabelkrant.asp?command=run&page=<%=nextpage%>";
// 			<% end if %>
// 		}
// 	</script>
// </head>

// <body scroll="no" background="<%=background%>">

// <% if len(rssTitle) > 0 then %>
// <h1><%=server.htmlEncode(rssTitle)%></h1>
// <% end if %>

// <p>
// 	<% if len(rssImage) > 0 then %>
// 	<img src="<%=rssImage%>" <%=rssImageAttr%> style="border: 20px solid #004380; margin-bottom: 20px; margin-right: 20px;">
// 	<% end if %>
// 	<%=rssInhoud%>
// </p>


// <script language="JavaScript">
// 	setTimeout('nextpage()', <%=seconden%>000);
// </script>


// <span id="clock" name="clock" class="underline"></span>


// <script language="JavaScript">
// 	showtime();
// </script>


// </body>
// </html>
// <%
// end sub

// function random(wiLow, wiHigh)
// 	randomize
// 	random = Int((wiHigh - wiLow + 1) * Rnd) + wiLow
// end function

// function getExternalXML(url)
// 	  'Declare the variables, and set the value of the variable url as 
// 	  'the full URL of the requested page.
// 	  Dim xml, strData
	
// 	  'Next, create an instance of the MS XMLhttp component.
// 	  'old version, unstable server side performance so upgrade if you can
// 	  ' *** OLD *** Set xml = Server.CreateObject("Microsoft.XMLHTTP")
		
// 	  'new version, better server side performance
// 	  Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
	
// 	  'Now open the connection, and send the request to the remote server. You 
// 	  'need to set the optional Async parameter to True on the open method for 
// 	  'this script to work. Otherwise, the waitForResponse method used 
// 	  'below will have no effect.
// 	  xml.Open "GET", url, true    ' the True specifies an asynchronous request
// 	  Call xml.Send()
	
// 	  'Turn off error handling
// 	  On Error Resume Next
	  
// 	  'Wait for up to 3 seconds if we've not gotten the data yet
// 	  If xml.readyState <> 4 then
// 	    xml.waitForResponse 30 ' 30
// 	  End If
	
// 	  'Did an error occur?  If so, use a default value for our data
// 	  If Err.Number <> 0 then
// 	    strData = "error"
// 	  Else
// 	    If (xml.readyState <> 4) Or (xml.Status <> 200) Then
// 	      'Abort the XMLHttp request
// 	      xml.Abort
	            
// 		  strData = "error"
// 	    Else
// 	      strData = xml.ResponseXML.xml
// 	    End If
// 	  End If
// 	getExternalXML = strData
// end function

// Function Base64Encode(inData)
// 	'ripped from: 
// 	'http://www.pstruh.cz/tips/detpg_Base64Encode.htm
// 	'rfc1521
// 	'2001 Antonin Foller, PSTRUH Software, http://pstruh.cz
// 	Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
// 	Dim sOut, I
  
// 	'For each group of 3 bytes
// 	For I = 1 To Len(inData) Step 3
// 		Dim nGroup, pOut
    
// 		'Create one long from this 3 bytes.
// 		nGroup = &H10000 * Asc(Mid(inData, I, 1)) + _
// 			&H100 * MyASC(Mid(inData, I + 1, 1)) + _
// 			MyASC(Mid(inData, I + 2, 1))
    
// 		'Oct splits the long To 8 groups with 3 bits
// 		nGroup = Oct(nGroup)
    
// 		'Add leading zeros
// 		nGroup = String(8 - Len(nGroup), "0") & nGroup
    
// 		'Convert To base64
// 		pOut = Mid(Base64, CLng("&o" & Mid(nGroup, 1, 2)) + 1, 1) + _
// 			Mid(Base64, CLng("&o" & Mid(nGroup, 3, 2)) + 1, 1) + _
// 			Mid(Base64, CLng("&o" & Mid(nGroup, 5, 2)) + 1, 1) + _
// 			Mid(Base64, CLng("&o" & Mid(nGroup, 7, 2)) + 1, 1)
    
// 		'Add the part To OutPut string
// 		sOut = sOut + pOut
    
// 	Next
// 	Select Case Len(inData) Mod 3
//     Case 1: '8 bit final
// 		sOut = Left(sOut, Len(sOut) - 2) + "=="
//     Case 2: '16 bit final
// 		sOut = Left(sOut, Len(sOut) - 1) + "="
// 	End Select
// 	Base64Encode = sOut
// End Function

// Function MyASC(OneChar)
// 	If OneChar = "" Then MyASC = 0 Else MyASC = Asc(OneChar)
// End Function
?>